package crond

import (
	"context"
	"time"

	"device-admin/config/redis"
	"device-admin/internal/app/web/service/device"
	"device-admin/internal/define"
)

// DeviceCacheCheck 设备列表缓存
func DeviceCacheCheck() {
	redisCtx, redisCtxCancel := context.WithTimeout(context.Background(), time.Second*3)
	defer redisCtxCancel()
	exists, _ := redis.NewDB().Exists(redisCtx, define.RedisDeviceList).Result()
	if exists <= 0 {
		device.LoadAllDeviceToRedis()
	}
}
